package com.shop2cn.iapi.sqsellerquery.testcase;

import java.math.BigDecimal;
import java.text.SimpleDateFormat;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Date;
import java.util.List;
import java.util.Optional;

import org.apache.commons.lang3.StringUtils;
import org.junit.After;
import org.junit.AfterClass;
import org.junit.Before;
import org.junit.BeforeClass;
import org.junit.Test;
import org.junit.experimental.categories.Category;
import org.springframework.data.domain.Sort;
import org.springframework.data.domain.Sort.Direction;
import org.springframework.data.mongodb.core.query.Criteria;
import org.springframework.data.mongodb.core.query.Query;
import org.springframework.util.CollectionUtils;

import com.google.common.collect.Lists;
import com.shop2cn.iapi.shenqisettlement.parameter.bean.AgentProductBean;
import com.shop2cn.iapi.sqoptrade.resp.TradingServiceResp;
import com.shop2cn.iapi.sqsellerquery.parameter.ExportSqOrderInfosReq;
import com.shop2cn.iapi.sqsellerquery.service.ExportSqOrderInfosCall;
import com.shop2cn.iapi.sqsynctrade.paremeter.mongo.details.Product;
import com.shop2cn.iapi.sqsynctrade.paremeter.mongo.details.ProductProxyPo;
import com.ymatou.common.lang.CipherUtil;
import com.ymatou.iapi.synctrade.parameter.mongo.Order;
import com.ymatou.iapi.synctrade.service.TradingSyncService;
import com.ymatou.iapi.trading.sellerquery2.parameter.resp.ProxyExportOrderProductInfo;
import com.ymatou.iapi.trading.sellerquery2.parameter.resp.SellerExportedPartialOrderInfo;
import com.ymatou.iapi.trading.sellerquery2.parameter.resp.SellerExportedPartialOrderInfosResponse;
import com.ymt.core.tool.Logger;
import com.ymt.utils.annotation.TestCase;
import com.ymt.utils.annotation.TestSuite;
import com.ymt.utils.tag.P1;
import com.ymttest.business.service.SQPayGateWayCallService;
import com.ymttest.business.service.shenqi.DGSQBuildProxyChainCallService;
import com.ymttest.business.service.shenqi.SqTradingCallService;
import com.ymttest.common.order.userquery.util.OrderHelper;
import com.ymttest.database.mongo.OrderQueryWapper;
import com.ymttest.database.mongo.ProxyOrderIndexQueryWapper;
import com.ymttest.database.mongo.config.OrderField;
import com.ymttest.database.mongo.config.ProxyIndexField;
import com.ymttest.utils.DataUtil;
import com.ymttest.utils.YMTDateUtil;

@TestSuite
public class Ts_ExportSqOrderInfos {

	private static ExportSqOrderInfosReq exportSqOrderInfosReq;
	private static ExportSqOrderInfosCall exportSqOrderInfosCall;

	private static String key = "123456789";

	private static long autotest_goodsOwnerId = 500002490;

	@BeforeClass
	public static void setUp() {
		Logger.createResultFile("分批导出货头/直销商神器订单信息");
	}

	@Before
	public void caseUp() {

		exportSqOrderInfosReq = new ExportSqOrderInfosReq();
		exportSqOrderInfosCall = new ExportSqOrderInfosCall();
	}

	@AfterClass
	public static void tearDown() {
		Logger.generateResult(exportSqOrderInfosCall.getOpurl());
	}

	@After
	public void caseDown() {
		Logger.end();
	}

	private void verify() throws Exception {

		SellerExportedPartialOrderInfosResponse expectedResponse = new SellerExportedPartialOrderInfosResponse();
		SellerExportedPartialOrderInfosResponse actualResponse = exportSqOrderInfosCall
				.getExportSellerOrderInfosResponse();

		ConstructExpectedResponse(exportSqOrderInfosReq, expectedResponse);

		DataUtil.verify(expectedResponse.getSellerExportedPartialOrderInfos()
				.size(), actualResponse.getSellerExportedPartialOrderInfos()
				.size(), "验证SellerExportedPartialOrderInfos的订单数量");
		if (DataUtil.isNullOrEmpty(expectedResponse
				.getSellerExportedPartialOrderInfos()) == false) {
			List<SellerExportedPartialOrderInfo> actuals = actualResponse
					.getSellerExportedPartialOrderInfos();
			int i = 0;

			for (SellerExportedPartialOrderInfo expect : expectedResponse
					.getSellerExportedPartialOrderInfos()) {

				SellerExportedPartialOrderInfo actual = actuals.get(i);

				Logger.comment("开始验证orderId：" + actual.getOrderId());

				DataUtil.verifyEquals(expect.getOrderId(), actual.getOrderId(),
						"验证OrderId");
				DataUtil.verifyEquals(expect.getUserId(), actual.getUserId(),
						"验证UserId");
				DataUtil.verifyEquals(expect.getSellerId(),
						actual.getSellerId(), "验证SellerId");
				DataUtil.verifyEquals(expect.getGoodsOwnerId(),
						actual.getGoodsOwnerId(), "验证GoodsOwnerId");
				DataUtil.verifyEquals(expect.getSalesman(),
						actual.getSalesman(), "验证Salesman");
				DataUtil.verifyEquals(expect.getReceiver(),
						actual.getReceiver(), "验证Receiver");
				DataUtil.verifyEquals(expect.getPhone(), actual.getPhone(),
						"验证Phone");
				DataUtil.verifyEquals(expect.getAddress(), actual.getAddress(),
						"验证Address");
				DataUtil.verifyEquals(expect.getPostCode(),
						actual.getPostCode(), "验证PostCode");
				DataUtil.verifyEquals(expect.getLeaveWord(),
						actual.getLeaveWord(), "验证LeaveWord");
				DataUtil.verifyDecimalEquals(expect.getFreight(),
						actual.getFreight(), "验证Freight");
				DataUtil.verifyDecimalEquals(expect.getCashAmount(),
						actual.getCashAmount(), "验证cashAmount");
				DataUtil.verifyDecimalEquals(expect.getTotalAmount(),
						actual.getTotalAmount(), "验证totalAmount");
				DataUtil.verifyEquals(expect.getOrderState(),
						actual.getOrderState(), "验证orderState");
				DataUtil.verifyDateEquals(expect.getAddTime(),
						actual.getAddTime(), "验证addTime");
				DataUtil.verifyDateEquals(expect.getPayTime(),
						actual.getPayTime(), "验证payTime");
				DataUtil.verifyDateEquals(expect.getDeliveryTime(),
						actual.getDeliveryTime(), "验证DeliveryTime");
				DataUtil.verifyEquals(expect.getBuyerLoginId(),
						actual.getBuyerLoginId(), "验证buyerLoginId");
				DataUtil.verifyEquals(expect.getDeliveryType(),
						actual.getDeliveryType(), "验证deliveryType");
				DataUtil.verifyEquals(expect.getRemarkLevel(),
						actual.getRemarkLevel(), "验证RemarkLevel");

				List<ProxyExportOrderProductInfo> actualProductInfos = actual
						.getProxyExportOrderProductInfos();
				int j = 0;

				for (ProxyExportOrderProductInfo expectProduct : expect
						.getProxyExportOrderProductInfos()) {

					ProxyExportOrderProductInfo actualProduct = actualProductInfos
							.get(j);

					Logger.comment("校验商品productId："
							+ actualProduct.getProductId());

					DataUtil.verifyEquals(expectProduct.getProductId(),
							actualProduct.getProductId(), "验证productId");
					DataUtil.verifyEquals(expectProduct.getCatalogId(),
							actualProduct.getCatalogId(), "验证catalogId");
					DataUtil.verifyEquals(expectProduct.getSku(),
							actualProduct.getSku(), "验证sku");
					DataUtil.verifyEquals(expectProduct.getTitle(),
							actualProduct.getTitle(), "验证title");
					DataUtil.verifyEquals(expectProduct.getFirstCategoryId(),
							actualProduct.getFirstCategoryId(),
							"验证firstCategoryId");
					DataUtil.verifyEquals(expectProduct.getSecondCategoryId(),
							actualProduct.getSecondCategoryId(),
							"验证secondCategoryId");
					DataUtil.verifyEquals(expectProduct.getThirdCategoryId(),
							actualProduct.getThirdCategoryId(),
							"验证thirdCategoryId");
					DataUtil.verifyEquals(expectProduct.getBrandId(),
							actualProduct.getBrandId(), "验证brandId");
					DataUtil.verifyEquals(expectProduct.getPropertys(),
							actualProduct.getPropertys(), "验证propertys");
					DataUtil.verifyDecimalEquals(expectProduct.getSalePrice(),
							expectProduct.getSalePrice(), "验证salePrice");
					DataUtil.verifyEquals(expectProduct.getNum(),
							actualProduct.getNum(), "验证num");
				}

				i++;
			}
		}
	}

	private void ConstructExpectedResponse(
			ExportSqOrderInfosReq exportSqOrderInfosReq,
			SellerExportedPartialOrderInfosResponse response) throws Exception {

		List<SellerExportedPartialOrderInfo> infos = new ArrayList<SellerExportedPartialOrderInfo>();
		Criteria indexCriteria = generateSqCriteria(exportSqOrderInfosReq);
		Query indexQuery = Query.query(indexCriteria);
		indexQuery.fields().include(ProxyIndexField.OID);
		indexQuery.with(new Sort(Direction.DESC, ProxyIndexField.ADD_TIME));
		indexQuery.limit(1000);
		List<Long> orderIds = new ProxyOrderIndexQueryWapper().queryOrderId(
				indexQuery, exportSqOrderInfosReq.getSellerId());

		// query order
		if (!CollectionUtils.isEmpty(orderIds)) {

			Query query = new Query();
			Criteria criteria = Criteria.where(OrderField.ID).in(orderIds);
			query.addCriteria(criteria);
			query.fields().exclude("rfds").exclude("stls").exclude("dlv");
			query.with(new Sort(Direction.DESC, OrderField.ADD_TIME));
			List<Order> orders = new OrderQueryWapper().find(query);

			if (orders.size() >= 1000) {
				SimpleDateFormat formatter = new SimpleDateFormat(
						"yyyy-MM-dd'T'HH:mm:ss");
				response.setNextPartitionKey(formatter.format(orders.get(
						1000 - 1).getAddTime()));
			}

			infos = convertSqOrder(orders, exportSqOrderInfosReq.getSellerId());
		}

		response.setSellerExportedPartialOrderInfos(infos);
	}

	private Criteria generateSqCriteria(ExportSqOrderInfosReq req) {

		List<Criteria> criterias = new ArrayList<>();

		if (req.getOrderStartTime() != null && req.getOrderEndTime() != null) {
			criterias.add(Criteria.where(ProxyIndexField.ADD_TIME).gte(
					req.getOrderStartTime()));
			criterias.add(Criteria.where(ProxyIndexField.ADD_TIME).lt(
					req.getOrderEndTime()));
		}

		if (req.getSellerId() > 0) {
			criterias.add(Criteria.where(ProxyIndexField.SELLER_ID).is(
					req.getSellerId()));
		}

		if (!CollectionUtils.isEmpty(req.getOrderStates())) {
			criterias.add(Criteria.where(ProxyIndexField.TRADING_STATUS).in(
					req.getOrderStates()));
		}

		if (StringUtils.isNotBlank(req.getPartitionKey())) {

			Date searchDate = YMTDateUtil.getDate(req.getPartitionKey(),
					YMTDateUtil.YMDTHMS_STRING);

			if (searchDate != null) {
				criterias.add(Criteria.where(ProxyIndexField.ADD_TIME).lte(
						searchDate));
			}
		}

		if (!CollectionUtils.isEmpty(req.getDeliveryType())) {
			criterias.add(Criteria.where(ProxyIndexField.DELIVERY_TYPE).in(
					req.getDeliveryType()));
		}

		return new Criteria().andOperator(criterias.toArray(new Criteria[0]));
	}

	private List<SellerExportedPartialOrderInfo> convertSqOrder(
			List<Order> orders, long reqSellerId) throws Exception {

		List<SellerExportedPartialOrderInfo> proxyExportOrderInfos = new ArrayList<SellerExportedPartialOrderInfo>();

		if (!CollectionUtils.isEmpty(orders)) {
			for (Order order : orders) {

				// 是否店主
				boolean isShopOwner = (reqSellerId == order.getSellerId());
				// 是否渠道商
				boolean isGoodsOwner = (reqSellerId == order.getGoodsOwnerId());

				SellerExportedPartialOrderInfo proxyExportOrderInfo = new SellerExportedPartialOrderInfo();

				proxyExportOrderInfo.setSellerId(order.getSellerId());
				proxyExportOrderInfo.setUserId(order.getUserId());
				proxyExportOrderInfo.setGoodsOwnerId(order.getGoodsOwnerId());
				proxyExportOrderInfo.setSalesman(order.getSalesman());

				proxyExportOrderInfo.setOrderId(order.getId());
				proxyExportOrderInfo.setReceiver(order.getReceiver());
				proxyExportOrderInfo.setAddress(CipherUtil.decryptAES(key,
						order.getUaddress()));
				proxyExportOrderInfo.setPostCode(order.getPostCode());
				proxyExportOrderInfo.setPhone(CipherUtil.decryptAES(key,
						order.getUphone()));
				proxyExportOrderInfo.setEmail(order.getEmail());
				proxyExportOrderInfo.setRemarkLevel(order.getRemarkLevel());
				proxyExportOrderInfo.setLeaveWord(order.getComment());
				proxyExportOrderInfo.setOrderNote(order.getContent());
				proxyExportOrderInfo.setFreight(order.getFreight());
				proxyExportOrderInfo.setOrderState(order.getTradingStatus());
				proxyExportOrderInfo.setAddTime(order.getAddTime());
				proxyExportOrderInfo.setPayTime(order.getPaidTime());
				proxyExportOrderInfo.setDeliveryTime(order.getDeliveryTime());
				proxyExportOrderInfo.setDeliveryType(order
						.getShenqiLogisticsType());
				proxyExportOrderInfo.setBuyerLoginId(order.getSellerLogin());
				BigDecimal totalAmount = BigDecimal.ZERO;

				List<ProxyExportOrderProductInfo> proxyExportOrderProductInfos = Lists
						.newArrayListWithCapacity(order.getProducts().size());

				for (Product product : order.getProducts()) {

					ProxyExportOrderProductInfo proxyExportOrderProductInfo = new ProxyExportOrderProductInfo();
					proxyExportOrderProductInfo.setProductId(product
							.getProductId());
					proxyExportOrderProductInfo.setCatalogId(product
							.getCataId());
					proxyExportOrderProductInfo.setSku(product.getSku());
					proxyExportOrderProductInfo.setTitle(product.getTitle());
					proxyExportOrderProductInfo.setFirstCategoryId(product
							.getCata1Id());
					proxyExportOrderProductInfo.setSecondCategoryId(product
							.getCata2Id());
					proxyExportOrderProductInfo.setThirdCategoryId(product
							.getCata3Id());
					proxyExportOrderProductInfo
							.setBrandId(product.getBrandId());
					proxyExportOrderProductInfo.setPropertys(product
							.getPropertyInfo());
					proxyExportOrderProductInfo.setNum(product.getPrdCount());
					// 销售价
					proxyExportOrderProductInfo.setSalePrice(product
							.getPrdPrice());

					// 直销商品的代理链不存在
					if (!CollectionUtils.isEmpty(order.getProductProxies())) {
						Optional<ProductProxyPo> productProxyOptional = order
								.getProductProxies()
								.stream()
								// 获取代理价，商品规格id相同 并且 sellerId与传入的sellerId相同
								.filter(pp -> pp.getCatalogId().equals(
										product.getCataId())
										&& pp.getSellerId() == reqSellerId)
								.findFirst();

						if (productProxyOptional.isPresent()) {
							ProductProxyPo productProxy = productProxyOptional
									.get();
							// 非渠道商设置代理价
							if (!isGoodsOwner) {
								proxyExportOrderProductInfo
										.setProxyPrice(productProxy
												.getFromParentPrice());
							}

							// 非店主设置销售价
							if (!isShopOwner) {
								proxyExportOrderProductInfo
										.setSalePrice(productProxy
												.getToChildPrice());
								proxyExportOrderProductInfo
										.setTitle(productProxy.getTitle());
								totalAmount = totalAmount.add(productProxy
										.getToChildPrice().multiply(
												new BigDecimal(product
														.getPrdCount())));
							}
						}
					}
					proxyExportOrderProductInfos
							.add(proxyExportOrderProductInfo);
				}

				if (isShopOwner) {
					proxyExportOrderInfo.setCashAmount(OrderHelper
							.getPayableAmount(order));
					proxyExportOrderInfo.setTotalAmount(order.getTotalPrice());
				} else {
					// 非售出人 商品总价也显示为下级代理的价格乘以数量
					proxyExportOrderInfo.setTotalAmount(totalAmount);
				}

				proxyExportOrderInfo
						.setProxyExportOrderProductInfos(proxyExportOrderProductInfos);
				proxyExportOrderInfos.add(proxyExportOrderInfo);
			}
		}

		return proxyExportOrderInfos;
	}

	@Test
	@Category(P1.class)
	@TestCase
	public void Tc_ExportSqOrderInfos_001() {
		Logger.start(true, "店主下单, 货头分批导出神器订单信息");
		try {

			Date orderStartTime = YMTDateUtil.getDate();
			AgentProductBean productBean = DGSQBuildProxyChainCallService
					.createProxychain((int) autotest_goodsOwnerId, 1, false);
			SqTradingCallService.placeOrder(productBean);

			exportSqOrderInfosReq.setSellerId(autotest_goodsOwnerId);
			exportSqOrderInfosReq.setOrderStartTime(orderStartTime);
			exportSqOrderInfosReq.setOrderEndTime(YMTDateUtil.getDate());
			exportSqOrderInfosReq.setPartitionKey("");

			exportSqOrderInfosCall.setData(exportSqOrderInfosReq);
			exportSqOrderInfosCall.callService();

			Logger.verifyEquals("200", exportSqOrderInfosCall.getCode(),
					"验证code");
			verify();
		} catch (Exception e) {
			Logger.fail(e);
		}
	}

	@Test
	@Category(P1.class)
	@TestCase
	public void Tc_ExportSqOrderInfos_002() {
		Logger.start(true, "店主下单, 店主分批导出神器订单信息");
		try {

			Date orderStartTime = YMTDateUtil.getDate();
			AgentProductBean productBean = DGSQBuildProxyChainCallService
					.createProxychain((int) autotest_goodsOwnerId, 1, false);
			TradingServiceResp placeOrderResp = SqTradingCallService
					.placeOrder(productBean);

			long sellerId = placeOrderResp.getOrderList().get(0).getSellerId();

			exportSqOrderInfosReq.setSellerId(sellerId);
			exportSqOrderInfosReq.setOrderStartTime(orderStartTime);
			exportSqOrderInfosReq.setOrderEndTime(YMTDateUtil.getDate());
			exportSqOrderInfosReq.setPartitionKey("");

			exportSqOrderInfosCall.setData(exportSqOrderInfosReq);
			exportSqOrderInfosCall.callService();

			Logger.verifyEquals("200", exportSqOrderInfosCall.getCode(),
					"验证code");
			verify();
		} catch (Exception e) {
			Logger.fail(e);
		}
	}

	@Test
	@Category(P1.class)
	@TestCase
	public void Tc_ExportSqOrderInfos_003() {
		Logger.start(true, "代理下单，代理分批导出神器订单信息");
		try {

			Date orderStartTime = YMTDateUtil.getDate();
			AgentProductBean productBean = DGSQBuildProxyChainCallService
					.createProxychain((int) autotest_goodsOwnerId, 1, true);
			TradingServiceResp placeOrderResp = SqTradingCallService
					.placeOrder(productBean);

			long sellerId = placeOrderResp.getOrderList().get(0).getSellerId();

			exportSqOrderInfosReq.setSellerId(sellerId);
			exportSqOrderInfosReq.setOrderStartTime(orderStartTime);
			exportSqOrderInfosReq.setOrderEndTime(YMTDateUtil.getDate());
			exportSqOrderInfosReq.setPartitionKey("");

			exportSqOrderInfosCall.setData(exportSqOrderInfosReq);
			exportSqOrderInfosCall.callService();

			Logger.verifyEquals("200", exportSqOrderInfosCall.getCode(),
					"验证code");
			verify();

		} catch (Exception e) {
			Logger.fail(e);
		}
	}

	@Test
	@Category(P1.class)
	@TestCase
	public void Tc_ExportSqOrderInfos_004() {
		Logger.start(true, "用户无可导出的订单");
		try {

			Date orderStartTime = YMTDateUtil.getDate();
			AgentProductBean productBean = DGSQBuildProxyChainCallService
					.createProxychain((int) autotest_goodsOwnerId, 1, true);
			TradingServiceResp placeOrderResp = SqTradingCallService
					.placeOrder(productBean);

			long sellerId = placeOrderResp.getOrderList().get(0).getSellerId();

			exportSqOrderInfosReq.setSellerId(sellerId + 1);
			exportSqOrderInfosReq.setOrderStartTime(orderStartTime);
			exportSqOrderInfosReq.setOrderEndTime(YMTDateUtil.getDate());
			exportSqOrderInfosReq.setPartitionKey("");

			exportSqOrderInfosCall.setData(exportSqOrderInfosReq);
			exportSqOrderInfosCall.callService();

			Logger.verifyEquals("200", exportSqOrderInfosCall.getCode(),
					"验证code");

			Logger.verifyEquals(0, exportSqOrderInfosCall
					.getExportSellerOrderInfosResponse()
					.getSellerExportedPartialOrderInfos().size(),
					"验证sellerExportedPartialOrderInfos");

		} catch (Exception e) {
			Logger.fail(e);
		}
	}

	@Test
	@Category(P1.class)
	@TestCase
	public void Tc_ExportSqOrderInfos_005() {
		Logger.start(true, "直销商下单，直销商分批导出神器订单信息");
		try {

			Date orderStartTime = YMTDateUtil.getDate();
			AgentProductBean productBean = DGSQBuildProxyChainCallService
					.createProxychain((int) autotest_goodsOwnerId, 1, true);
			TradingServiceResp placeOrderResp = SqTradingCallService
					.placeOrder(productBean, productBean.getSellerId());

			long sellerId = placeOrderResp.getOrderList().get(0).getSellerId();

			exportSqOrderInfosReq.setSellerId(sellerId);
			exportSqOrderInfosReq.setOrderStartTime(orderStartTime);
			exportSqOrderInfosReq.setOrderEndTime(YMTDateUtil.getDate());
			exportSqOrderInfosReq.setPartitionKey("");

			exportSqOrderInfosCall.setData(exportSqOrderInfosReq);
			exportSqOrderInfosCall.callService();

			Logger.verifyEquals("200", exportSqOrderInfosCall.getCode(),
					"验证code");

			this.verify();

		} catch (Exception e) {
			Logger.fail(e);
		}
	}

	@Test
	@Category(P1.class)
	@TestCase
	public void Tc_ExportSqOrderInfos_006() {
		Logger.start(true, "直销商发货，直销商分批导出神器订单信息");
		try {

			Logger.comment("前置数据准备开始");
			Date orderStartTime = YMTDateUtil.getDate();
			AgentProductBean productBean = DGSQBuildProxyChainCallService
					.createProxychain((int) autotest_goodsOwnerId, 1, true);
			TradingServiceResp placeOrderResp = SqTradingCallService
					.placeOrder(productBean, productBean.getSellerId());

			long sellerId = placeOrderResp.getOrderList().get(0).getSellerId();

			Long userId = placeOrderResp.getUserId();
			long orderId = placeOrderResp.getOrderList().get(0).getOrderId();
			BigDecimal totalPrice = placeOrderResp.getPayableAmount();

			// 支付订单
			Long thirdTradingId = SqTradingCallService.payOrder(userId,
					placeOrderResp.getTradingId());

			// 支付网关支付回调交易
			SQPayGateWayCallService.DGSQNotifyCall(
					String.valueOf(thirdTradingId),
					totalPrice.subtract(BigDecimal.ZERO).toString(),
					userId.intValue(), BigDecimal.ZERO.toPlainString());

			TradingSyncService.getSyncResult(orderId);
			Thread.sleep(3000);

			// 接单
			SqTradingCallService.sellerAcceptOrder(sellerId, orderId);
			TradingSyncService.getSyncResult(orderId);

			Thread.sleep(5000);

			// 神器订单发货
			SqTradingCallService.delivery(sellerId, orderId, 1L, null);
			TradingSyncService.getSyncResult(orderId);

			Logger.comment("前置数据准备结束");

			exportSqOrderInfosReq.setSellerId(sellerId);
			exportSqOrderInfosReq.setOrderStartTime(orderStartTime);
			exportSqOrderInfosReq.setOrderEndTime(YMTDateUtil.getDate());
			exportSqOrderInfosReq.setOrderStates(Arrays.asList(3));
			exportSqOrderInfosReq.setPartitionKey("");

			exportSqOrderInfosCall.setData(exportSqOrderInfosReq);
			exportSqOrderInfosCall.callService();

			Logger.verifyEquals("200", exportSqOrderInfosCall.getCode(),
					"验证code");

			this.verify();

		} catch (Exception e) {
			Logger.fail(e);
		}
	}

	@Test
	@Category(P1.class)
	@TestCase
	public void Tc_ExportSqOrderInfos_007() {
		Logger.start(true, "不传入sellerId");
		try {

			exportSqOrderInfosReq.setPartitionKey("");

			exportSqOrderInfosCall.setData(exportSqOrderInfosReq);
			exportSqOrderInfosCall.callService();

			Logger.verifyEquals("sellerId:商家Id不能为空",
					exportSqOrderInfosCall.getMsg(), "验证msg");

		} catch (Exception e) {
			Logger.fail(e);
		}
	}

	@Test
	@Category(P1.class)
	@TestCase
	public void Tc_ExportSqOrderInfos_008() {
		Logger.start(true, "下单的物流为999，但是查询的为100");
		try {

			Date orderStartTime = YMTDateUtil.getDate();
			AgentProductBean productBean = DGSQBuildProxyChainCallService
					.createProxychain((int) autotest_goodsOwnerId, 1, true);
			TradingServiceResp placeOrderResp = SqTradingCallService
					.placeOrder(productBean, productBean.getSellerId());

			long sellerId = placeOrderResp.getOrderList().get(0).getSellerId();

			exportSqOrderInfosReq.setSellerId(sellerId);
			exportSqOrderInfosReq.setOrderStartTime(orderStartTime);
			exportSqOrderInfosReq.setOrderEndTime(YMTDateUtil.getDate());
			exportSqOrderInfosReq.setDeliveryType(Arrays.asList(100));
			exportSqOrderInfosReq.setPartitionKey("");

			exportSqOrderInfosCall.setData(exportSqOrderInfosReq);
			exportSqOrderInfosCall.callService();

			Logger.verifyEquals(0, exportSqOrderInfosCall
					.getExportSellerOrderInfosResponse()
					.getSellerExportedPartialOrderInfos().size(),
					"验证sellerExportedPartialOrderInfos");

		} catch (Exception e) {
			Logger.fail(e);
		}
	}
}